<%@ page language="java" import="java.util.*,com.model.entity.*"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>学员管理系统</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<link rel="stylesheet" type="text/css" href="css/style.css">
		<link rel="stylesheet" type="text/css" href="css/demo.css">
		<script type="text/javascript" src="js/js.js"></script>
		<script type="text/javascript">
	function edit() {
		var el = document.getElementsByTagName('input');
		var len = el.length;
		var m = 0;
		for ( var i = 0; i < len; i++) {
			if ((el[i].type == "checkbox") && (el[i].checked == true)) {
				m++
			}
		}
		alert(m);
		if (m > 0) {
			if(m==1){
			document.frmAction.action = "Student_edit.action";
			document.frmAction.submit();
			alert("edit");
			}else{
             alert("只能选中一个")
             //window.history.back(-1);
           //  window.location.href = "Student_list.action";
				}
		} else {
			alert("没有选中");
			//window.history.back(-1);
			//window.location.href = "Student_list.action";
		}

	}

	function del() {
		//window.location.href="delstudent.jsp"; 
		var el = document.getElementsByTagName('input');
		var len = el.length;
		var m = 0;
		for ( var i = 0; i < len; i++) {
			if ((el[i].type == "checkbox") && (el[i].checked == true)) {
				m++
			}
		}
		
		if (m > 0) {
            
				document.frmAction.action = "Student_delete.action";
				document.frmAction.submit();
				alert("del");
				
				
		} else {
			alert("没有选中");
			window.location.href = "Student_list.action";
		}

	}
</script>

	</head>
	<body topmargin="10" leftmargin="10">
		<form name="frmAction" method="post" action="add.jsp">
			<table width="100%" class="toolBar" id="toggleDemoTable"
				class="tex004">
				<tr>
					<td>
						欢迎你:&nbsp;${stuname}&nbsp;&nbsp;
						<a href="login.jsp">重新登录</a>
					</td>
					<td id="addbutton" align="right">
						<a href="addstudent.jsp"> <input type="button"
								onclick=
	showAdd();;
value="增加"> </a> &nbsp;&nbsp;
						<input type="button" onclick=
	edit();;
value="编辑">
						&nbsp;&nbsp;
						<input type="button" onclick=
	del();;
value="删除">
						&nbsp;&nbsp;
						<a href="selectstudent.jsp"><input type="button"
								onclick=
	query();;;
value="查询"> </a> &nbsp;&nbsp;
					</td>
				</tr>
			</table>

			<table width="100%" border="0" cellpadding="3" cellspacing="1"
				class="toolTable">
				<!--此处为列标题-->
				<tr align="center" class="colom">
					<td>
						<input type="checkBox" width="10%" name="chkAll"
							onClick=
	selectAll();;;
/>
					</td>
					<td align='center' width="20%">
						姓名
					</td>
					<td width="20%">
						学号
					</td>
					<td width="10%">
						性别
					</td>
					<td width="20%">
						出生日期
					</td>
					<td width="20%">
						政治面貌
					</td>
				</tr>

				<c:forEach items="${requestScope.list}" var="student"
					varStatus="sta">
					<tr class='even'>
						<td align='center'>

							<input type="checkbox" name="chkStudent" value="${student.id}">

							<td align=center>
								<a href='Student_detail.action?stuname=${student.stuname}'
									title='查询学生详细信息'>${student.stuname}</a>
							</td>
							<td align=center>
								${student.stunumber}
							</td>
							<td align=center>
								<c:if test="${student.sex == 1}">
								男
							</c:if>
								<c:if test="${student.sex==2 }">
								女
							</c:if>
							</td>
							<td align=center>
								${student.birthday}
							</td>
							<td align=center>
								<c:choose>
									<c:when test="${student.stuPolity==1}">党员</c:when>
									<c:when test="${student.stuPolity==2}">团员</c:when>
									<c:when test="${student.stuPolity==3}">无党派</c:when>
									<c:otherwise>其他</c:otherwise>
								</c:choose>
							</td>
						</td>
					</tr>
				</c:forEach>
			</table>
			<!-- 判断是否显示分页控制栏 -->
			<c:if test="${pageController != null }">
				<jsp:include page="./dispage.jsp"></jsp:include>
			</c:if>
			<!-- 如果 集合对象中没有任何数据，提示用户，当前没有数据 -->
			<c:if test="${empty  requestScope.list}">
				<div class="feat_prod_box">
					抱歉当前没有符合条件的记录!
				</div>
			</c:if>
			${sessionScope.msg}
		</form>


	</body>

</html>
